// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })

const db = cloud.database()
// 云函数入口函数
exports.main = async (event) => {
    const { locationId, userId } = event
    const locationInfo = await db.collection('location').doc(locationId).get() //宠物信息
    const userInfo = await db.collection('userInfo').doc(userId).get() //用户信息

    return {
        data:{
        ...locationInfo.data,
        like: userInfo.data.likeLocationIds && userInfo.data.likeLocationIds.includes(locationInfo.data._id)}
    }
}